package frame.model;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Date;

/**
 * @author 王迎澳
 * @version 1.0
 * @school hhu
 * @date 2022/5/30 11:00
 */
public class Main {

    public void init() throws Exception{
        Class.forName("org.opengauss.Driver");
        Connection con = DriverManager.getConnection("jdbc:opengauss://121.36.41.207:26000/finance", "geqiyu", "Tlyz0729");
        PreparedStatement preparedStatement1 = con.prepareStatement("select * from websites");
        PreparedStatement preparedStatement2 = con.prepareStatement("SET SEARCH_PATH TO finance,public;");
        preparedStatement2.execute();
        ResultSet resultSet = preparedStatement1.executeQuery();
        while(resultSet.next()) {
            String id = resultSet.getString("id");
            String name = resultSet.getString("name");
            String url = resultSet.getString("url");
            System.out.println("id = " + id);
            System.out.println("name = " + name);
            System.out.println("url = " + url);
        }
        resultSet.close();
        preparedStatement1.close();
        preparedStatement2.close();
        con.close();
    }

    public static void main(String[] args){
    }
}